/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aptech.DAO;

import com.aptech.model.Bank;
import com.aptech.model.RealEstateType;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author Hoang Quy Hong An
 */
public class bankDAO {

        private  Connection myCon = null;
    private  PreparedStatement ps = null;
    private  ResultSet rs = null;
    private String strCommand = "";

    public  ArrayList<Bank> getAllBank() {
        System.out.println("Goi den day lan thu nhat!");
        ArrayList<Bank> listBank = new ArrayList<Bank>();
        Bank objBank = null;
        strCommand = "SELECT  bankID , bankName FROM tbl_Banks WHERE bankStatus = 1";
        try {
            myCon = myConnection.getConnection();
            ps = myCon.prepareStatement(strCommand, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs = ps.executeQuery();
            while (rs.next()) {
                
                objBank = new Bank();
                objBank.setBankID(rs.getInt("bankID"));
                objBank.setBankName(rs.getString("bankName"));
                listBank.add(objBank);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myConnection.closeConnection(myCon, ps, rs);
        }
        return listBank;
    }
}
